{{!
  Copyright (c) HashiCorp, Inc.
  SPDX-License-Identifier: BUSL-1.1
~}}

<div class="has-text-right">
  <Hds::Dropdown @isInline={{true}} @listPosition="bottom-right" as |dd|>
    <dd.ToggleIcon
      @icon="more-horizontal"
      @text="Alias management options"
      @hasChevron={{false}}
      data-test-popup-menu-trigger
    />
    <dd.Interactive
      @route="vault.cluster.access.identity.aliases.show"
      @models={{array (pluralize @item.parentType) @item.id "details"}}
    >Details</dd.Interactive>
    {{#if @item.updatePath.isPending}}
      <dd.Generic class="has-text-center">
        <LoadingDropdownOption />
      </dd.Generic>
    {{else}}
      {{#if @item.canEdit}}
        <dd.Interactive
          @route="vault.cluster.access.identity.aliases.edit"
          @models={{array (pluralize @item.parentType) @item.id}}
        >Edit</dd.Interactive>
      {{/if}}
      {{#if @item.canDelete}}
        <dd.Interactive
          @color="critical"
          {{on "click" (fn (mut this.showConfirmModal) true)}}
          data-test-popup-menu="delete"
        >Remove</dd.Interactive>
      {{/if}}
    {{/if}}
  </Hds::Dropdown>
</div>

{{#if this.showConfirmModal}}
  <ConfirmModal @color="critical" @onClose={{fn (mut this.showConfirmModal) false}} @onConfirm={{this.deleteAlias}} />
{{/if}}